package cn.gov.pbc.gd.credit.vo.corp;

import java.io.Serializable;
import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;

import com.alibaba.fastjson.annotation.JSONField;

/**
 * Class Describe
 * <p>
 * User: yangguang
 * Date: 17/8/28
 * Time: 下午5:05
 */
public class ResCorpCoverVo implements Serializable{


    /**
	 * 
	 */
	private static final long serialVersionUID = 6319204067785200278L;


	/**
     * ID
     */
    private String id;


    /**
     * Database Column Remarks:
     * 父id,根目录为 -1
     * <p>
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_credit_corp.parent_id
     *
     * @mbg.generated
     */
    private String parentId;

    /**
     * Database Column Remarks:
     * 公司名称
     * <p>
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_credit_corp.name
     *
     * @mbg.generated
     */
    private String name;

    /**
     * Database Column Remarks:
     * 名称拼音
     * <p>
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_credit_corp.name_pinyin
     *
     * @mbg.generated
     */
    private String namePinyin;

    /**
     * Database Column Remarks:
     * 公司简称
     * <p>
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_credit_corp.short_name
     *
     * @mbg.generated
     */
    private String shortName;

    /**
     * Database Column Remarks:
     * 状态:0-新建，1-正常，2-注销
     * <p>
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_credit_corp.status
     *
     * @mbg.generated
     */
    private Integer status;

    /**
     * Database Column Remarks:
     * 公司简称
     * <p>
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_credit_corp.note
     *
     * @mbg.generated
     */
    private String note;

    /**
     * Database Column Remarks:
     * 修改人
     * <p>
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_credit_corp.update_by
     *
     * @mbg.generated
     */
    private String updateBy;

    /**
     * Database Column Remarks:
     * 修改时间
     * <p>
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_credit_corp.update_time
     *
     * @mbg.generated
     */
    private Date updateTime;

    /**
     * Database Column Remarks:
     * 创建人
     * <p>
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_credit_corp.create_by
     *
     * @mbg.generated
     */
    private String createBy;

    /**
     * Database Column Remarks:
     * 创建时间
     * <p>
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_credit_corp.create_time
     *
     * @mbg.generated
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     * 上级企业
     */
    private ResCorpCoverVo parent;

    /**
     * 层级  现在只支持3级
     */
    private Integer leave;


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getNamePinyin() {
        return namePinyin;
    }

    public void setNamePinyin(String namePinyin) {
        this.namePinyin = namePinyin;
    }

    public String getShortName() {
        return shortName;
    }

    public void setShortName(String shortName) {
        this.shortName = shortName;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public String getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(String updateBy) {
        this.updateBy = updateBy;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public ResCorpCoverVo getParent() {
        return parent;
    }

    public void setParent(ResCorpCoverVo parent) {
        this.parent = parent;
    }

    public Integer getLeave() {
        return countLeave(this, 1);
    }

    private int countLeave(ResCorpCoverVo vo, Integer count) {
        if (vo.getParentId().equalsIgnoreCase("-1")) {
            return count;
        } else {
            count += 1;
            return countLeave(vo.getParent(), count);
        }
    }

	public void setLeave(Integer leave) {
		this.leave = leave;
	}


}
